#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1

# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
CROSS= --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
else
CROSS= --build $(DEB_BUILD_GNU_TYPE)
endif

# make sure pkg_config is looking in the right directories
export PKG_CONFIG_LIBDIR=/usr/$(DEB_HOST_GNU_TYPE)/lib/pkgconfig/

# The nzbget configure script somehow want to add the default /usr/include directory to the include path, which
# creates a lot of compile problems. Setting LIBPREF prevents this from hapening.
export LIBPREF=/usr/$(DEB_HOST_GNU_TYPE)

%:
	dh $@ 

override_dh_auto_install:
	make -j1 install DESTDIR=debian/nzbget
	install -d debian/nzbget/etc
	install -oroot -groot -m644 nzbget.conf.example      debian/nzbget/etc/nzbget.conf
	install -oroot -groot -m644 postprocess-example.conf debian/nzbget/etc/postprocess-example.conf
	install -oroot -groot -m755 postprocess-example.sh   debian/nzbget/etc/postprocess-example.sh
